//
//  MainTabBarController.m
//  item-NetEaseNews-tyw
//
//  Created by tyw on 15/9/29.
//  Copyright (c) 2015年 tyw. All rights reserved.
//

#import "MainTabBarController.h"

#import "NewsViewController.h"
#import "ReaderViewController.h"
#import "MediaViewController.h"
#import "FoundViewController.h"
#import "MeViewController.h"

@interface MainTabBarController ()

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addVCs];
}

- (void)addVCs {
    NSArray* navNameArray = @[@"NewsViewController",
                              @"ReaderViewController",
                              @"MediaViewController",
                              @"FoundViewController",
                              @"MeViewController"];
    NSMutableArray* navArray = [[NSMutableArray alloc] init];
    
    NSArray* titleArray = @[@"新闻",@"阅读",@"视听",@"发现",@"我"];
    NSArray* imageArray = @[@"news",@"reader",@"media",@"found",@"me"];
    for ( int i = 0; i < 5; i++) {
        //添加视图控制器们
        UIViewController* vc = [[NSClassFromString(navNameArray[i]) alloc] init];
        UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:vc];
        [navArray addObject:nav];
        //设置tabbarItem
        NSString* imgNormalName = [NSString stringWithFormat:@"tabbar_icon_%@_normal",imageArray[i]];
        NSString* imgHighlightName = [NSString stringWithFormat:@"tabbar_icon_%@_highlight",imageArray[i]];
        UITabBarItem* tabBarItem = [[UITabBarItem alloc] initWithTitle:titleArray[i] image:[UIImage imageNamed:imgNormalName] tag:i+100];
        tabBarItem.selectedImage = [UIImage imageNamed:imgHighlightName];
        nav.tabBarItem = tabBarItem;
    }
    self.viewControllers = navArray;
    self.tabBar.tintColor = kNetEaseRedColor;
}

@end
